package com.yimi.yinhepda.utils;

import android.app.ProgressDialog;
import android.content.Context;

/**
 * @author 000432
 */
public class ProgressDialogTools {

  private static ProgressDialog dialog = null;

  public static void create(Context context, String msg) {
    if (dialog != null && !dialog.isShowing()) {
      dialog = null;
    }
    if (dialog == null) {
      dialog = new ProgressDialog(context);
    }

    dialog.setMessage(msg);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
  }

  public static void show() {
    if (dialog != null && !dialog.isShowing()) {
      dialog.show();
    }
  }

  public static void stop() {
    if (dialog != null && dialog.isShowing()) {
      dialog.dismiss();
      dialog = null;
    }
  }
}
